﻿using System;
using System.Collections.Generic;
using System.Text;
using Gammar.Price.ObjectModel;
using System.Globalization;
using Longbow.Data;

namespace Gammar.Price.DataAccess
{
    public partial class ViewOpenClassDetail
    {
        /// <summary>
        /// 通过类型获得所有实例集合
        /// </summary>
        /// <param name="criteria">[type]</param>
        /// <returns></returns>
        public ViewOpenClassDetailEntity[] RetrieveListById(string type, DBAccess dbAccess)
        {
            if (!string.IsNullOrEmpty(type))
                this.Criteria = string.Format(CultureInfo.InvariantCulture, "where [type] = '{0}'", type);
            return this.Execute(dbAccess);
        }

        /// <summary>
        /// 通过主键ID获得一个OpenClassEntity实例
        /// </summary>
        /// <param name="criteria">oc_id</param>
        /// <param name="dbAccess"></param>
        /// <returns></returns>
        public ViewOpenClassDetailEntity RetrieveItemById(string criteria, DBAccess dbAccess)
        {
            if (string.IsNullOrEmpty(criteria)) throw new ArgumentNullException("criteria");
            this._criteria = string.Format(CultureInfo.InvariantCulture, "where [oc_id] = '{0}'", criteria);
            ViewOpenClassDetailEntity[] ret = this.Execute(dbAccess);
            return ret.Length > 0 ? ret[0] : null;
        }
    }
}
